#coding=utf8
from __future__ import unicode_literals

from django.db import models
from django.contrib.auth.models import User  
from django.contrib import admin
from django.utils import timezone

#博文类型
class Type(models.Model):   
    type = models.CharField(max_length=10, verbose_name=u'类型')   
    class Meta:
        verbose_name = u'类型'
        verbose_name_plural = u'类型'
    def __unicode__(self):
        return self.type

class BaseInfo(models.Model):
    author = models.ForeignKey(User, verbose_name=u'作者')
    title =  models.CharField(max_length=50, verbose_name=u'标题', unique=True)
    timestamp = models.DateTimeField(verbose_name=u'创建时间', blank=True,null=True)
    clicktime = models.IntegerField(default=0,verbose_name=u'浏览')
    
    def __unicode__(self):
        return self.title
    
    class Meta:
        abstract = True

#博文               
class Blog(BaseInfo):
    blogtype = models.ForeignKey(Type, verbose_name=u'类型', default=1)
    body = models.TextField(verbose_name=u'内容')
    
    def __unicode__(self):
        return self.title
    
    class Meta:
        verbose_name = u'博客'
        verbose_name_plural = '博客'
        
#个人中心    
class Profile(models.Model):
    name = models.ForeignKey(User, verbose_name=u'作者')
    address = models.CharField(max_length=10, verbose_name=u'窝在何方')
    job = models.CharField(max_length=10, verbose_name=u'哪行工作')
    love = models.CharField(max_length=50, verbose_name=u'爱好')
    qq = models.CharField(max_length=15, verbose_name=u'企鹅号码')
    email = models.EmailField(verbose_name=u'邮箱')
    desc = models.TextField(verbose_name=u'个人介绍',blank=True)
    
    def __unicode__(self):
        return self.qq
    
    class Meta:
        verbose_name = u'个人信息'
        verbose_name_plural = u'个人信息'

#对博文的评论
class Comment(models.Model):
    blog = models.ForeignKey(Blog, verbose_name=u'评价的blog')
    timestamp = models.DateTimeField(verbose_name=u'创建时间', blank=True,null=True)
    agree = models.IntegerField(default=0,verbose_name=u'赞同数')
    content = models.CharField(max_length=200, verbose_name=u'评论内容')
    
    def __unicode__(self):
        return self.content
    
    class Meta:
        verbose_name = u'blog评论'
        verbose_name_plural = u'blog评论'
        
#旅行日志信息
class TravelInfo(BaseInfo):
    abstract = models.CharField(max_length=100, verbose_name=u'摘要', blank=True, null=True)
    like = models.IntegerField(default=0, verbose_name=u'点赞数')
    
    class Meta:
        verbose_name = u'旅行信息'
        verbose_name_plural = u'旅行信息'

#类型日志              
class Travel(models.Model):
    pic = models.ImageField(upload_to='img', verbose_name=u'旅行')
    picdesc = models.TextField(verbose_name=u'图片描述')
    body = models.ForeignKey(TravelInfo, verbose_name=u'旅行日志标题' )
    
    class Meta:
        verbose_name = u'旅行日志'
        verbose_name_plural = u'旅行日志'
        

#摄影集封面       
class PicInfo(BaseInfo):
    first_pic = models.ImageField(upload_to='pic', verbose_name=u'封面')
    
    class Meta:
        verbose_name = u'图片集信息'
        verbose_name_plural = u'图片集信息'

#摄影集        
class Pic(models.Model):
    pic = models.ImageField(upload_to='pic', verbose_name=u'图片')
    picinfo =  models.ForeignKey(PicInfo, verbose_name=u'图片信息' )
    
    class Meta:
        verbose_name = u'图片集'
        verbose_name_plural = u'图片集'

#对摄影集的评论
class PicComment(models.Model):
    picInfo = models.ForeignKey(PicInfo, verbose_name=u'摄影集')
    timestamp = models.DateTimeField(verbose_name=u'创建时间', blank=True,null=True)
    content = models.CharField(max_length=200, verbose_name=u'评论内容')
    
    def __unicode__(self):
        return self.content
    
    class Meta:
        verbose_name = u'摄影集评论'
        verbose_name_plural = u'摄影集评论'

#闲言碎语
class Xysy(models.Model):
    author = models.ForeignKey(User, verbose_name=u'作者')
    timestamp = models.DateTimeField(verbose_name=u'时间', blank=True,null=True)
    content = models.CharField(max_length=200, verbose_name=u'闲言碎语')
    
    def __unicode__(self):
        return self.content
    
    class Meta:
        verbose_name = u'闲言碎语'
        verbose_name_plural = u'闲言碎语' 

#留言板
class LeaveAMsg(models.Model):
    timestamp = models.DateTimeField(verbose_name=u'时间', blank=True,null=True)
    content = models.CharField(max_length=200, verbose_name=u'留言板')
    
    def __unicode__(self):
        return self.content
    
    class Meta:
        verbose_name = u'留言板'
        verbose_name_plural = u'留言板' 